package com.ssm.juc.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorsTest1 {

    public static void main(String[] args) {
        //1.创建线程池
        ExecutorService executorService1 = Executors.newCachedThreadPool();
        ExecutorService executorService2 = Executors.newFixedThreadPool(10);
        ExecutorService executorService3 = Executors.newSingleThreadExecutor();

        for (int i = 0; i < 100; i++) {
            int idx = i;
            //2.提交任务
            executorService1.submit(() ->
                    System.out.println(Thread.currentThread().getName() + " task execution i = " + idx));
        }
    }
}